package joindemo.service;

import com.baomidou.mybatisplus.extension.service.IService;
import joindemo.common.enums.ArticleVisibilityEnum;
import joindemo.domain.dto.ArticleDto;
import joindemo.domain.po.ArticlePo;
import joindemo.domain.query.ArticlePageQuery;
import joindemo.domain.query.ArticleSearchQuery;
import joindemo.domain.vo.ArticleVo;
import joindemo.domain.vo.PageVo;

/**
 * @author pym
 */
public interface IArticleService extends IService<ArticlePo> {

    /**
     * 发布文章
     */
    ArticleVo addArticle(ArticleDto articleDto, Long userId, String authorName);

    /**
     * 更新文章
     */
    ArticleVo updateArticle(Integer id, ArticleDto articleDto, Long userId);

    /**
     * 获取文章详情
     */
    ArticleVo getArticleById(Integer id);

    /**
     * 分页查询
     */
    PageVo<ArticleVo> pageArticles(ArticlePageQuery query);

    /**
     * 搜索文章
     */
    PageVo<ArticleVo> searchArticles(ArticleSearchQuery query);

    /**
     * 保存草稿
     */
    String saveDraft(Long userId, String draftId, ArticleDto articleDto);

    /**
     * 获取草稿
     */
    ArticleDto getDraft(Long userId, String draftId);

    /**
     * 删除草稿
     */
    void deleteDraft(Long userId, String draftId);

    /**
     * 更新可见性
     */
    void updateArticleVisibility(Integer id, ArticleVisibilityEnum visibility);

    /**
     * 用户删除文章
     */
    void deleteArticle(Integer id, Long userId);

    /**
     * 管理员删除文章
     */
    void deleteArticleByAdmin(Integer id);
}